import http from "@/service/request";
import type { params } from "../type";

enum API {
  //添加一个订单
  ADD_ORDER = "/api/shop/order",
  // 订单支付
  PAY_ORDER = "/api/shop/orderpay",
  // 更改订单的信息
  CHANGE_ORDER_INFO = "/api/shop/order/",
  CANCEL_ORDER = "",
}

export function api_add_order(data: order) {
  return http({
    method: "POST",
    url: API.ADD_ORDER,
    data,
  });
}

export function api_pay_order(data: order_id) {
  return http({
    method: "POST",
    url: API.PAY_ORDER,
    data,
  });
}

export function api_change_order_info(id: number, data: order) {
  return http({
    method: "PUT",
    url: API.CHANGE_ORDER_INFO + id,
    data,
  });
}

interface order {
  goods_info?: good_info[];
  addr_id?: number;
  shoppingCartIds?: number[];
  status?: number;
}

interface good_info {
  id: number;
  num: number;
}

interface order_id {
  id: number;
}
